﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WeChatParking.Core.Payment.Alipay
{
    public class AlipayDirectPayRequest
    {
        //====================基本参数=================
        /// <summary>
        /// 接口名称
        /// </summary>
        public string Service { get; set; }
        /// <summary>
        /// 合作者身份ID
        /// </summary>
        public string Partner { get; set; }

        /// <summary>
        /// 参数编码字符集
        /// </summary>
        public string InputCharset { get; set; }

        /// <summary>
        /// 签名方式  DSA、RSA、MD5
        /// </summary>
        public string SignType { get; set; }

        /// <summary>
        /// 签名 
        /// </summary>
        public string Sign { get; set; }

        /// <summary>
        /// 服务器异步通知页面路径   可空
        /// </summary>
        public string NotifyUrl { get; set; }

        /// <summary>
        /// 页面跳转同步通知页面路径  可空
        /// </summary>
        public string ReturnUrl { get; set; }

        /// <summary>
        /// 请求出错时的通知页面路径   可空
        /// </summary>
        public string ErrorNotifyUrl { get; set; }

        //====================业务参数=================

        /// <summary>
        /// 商户网站唯一订单
        /// </summary>
        public string OutTradeNo { get; set; }

        /// <summary>
        /// 商品名称
        /// </summary>
        public string Subject { get; set; }
        /// <summary>
        /// 支付类型  默认值为1（商品购买）
        /// </summary>
        public string PaymentType { get; set; }

        /// <summary>
        /// 交易金额  精确小数点后两位
        /// </summary>
        public decimal TotalFee { get; set; }

        /// <summary>
        /// 卖家支付宝用户号
        /// </summary>
        public string SellerID { get; set; }

        /// <summary>
        /// 买家支付宝用户号   可空
        /// </summary>
        public string BuyerID { get; set; }


        /// <summary>
        /// 卖家支付宝账号  可空
        /// </summary>
        public string SellerEmail { get; set; }

        /// <summary>
        /// 买家支付宝账号   可空
        /// </summary>
        public string BuyerEmail { get; set; }



        /// <summary>
        /// 商品单价   可空
        /// </summary>
        public float? Price  { get; set; }

        /// <summary>
        /// 购买数量   可空
        /// </summary>
        public int? Quantity { get; set; }
        /// <summary>
        /// 商品描述   可空
        /// </summary>
        public string Body { get; set; }

        /// <summary>
        /// 商品展示网址   可空
        /// </summary>
        public string ShowUrl { get; set; }
        /// <summary>
        /// 默认支付方式  取值范围 creditPay,directPay 默认directPay 可空
        /// </summary>
        public string Paymethod { get; set; }

        /// <summary>
        /// 支付渠道   可空
        /// </summary>
        public string EnablePaymethod { get; set; }

        /// <summary>
        /// 公传回传参数   可空
        /// </summary>
        public string ExtraCommonParam { get; set; }

        public AlipayDirectPayRequest()
        {
            //Service = AlipayConfig.DirectPayService;
            Partner = AlipayConfig.Partner;
            InputCharset = AlipayConfig.Input_charset;
            SignType = AlipayConfig.Sign_type;
           // NotifyUrl = AlipayConfig.NotifyUrl;
            ReturnUrl = AlipayConfig.ReturnUrl;
            ErrorNotifyUrl = AlipayConfig.ErrorNotifyUrl;
            SellerEmail = AlipayConfig.Seller_email;
            PaymentType = "1";
        }

        public Dictionary<string, string> GetParameters()
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("service", this.Service);
            parameters.Add("partner", this.Partner);
            parameters.Add("_input_charset", this.InputCharset);
            parameters.Add("sign_type", this.SignType);
            parameters.Add("sign", this.Sign);
            parameters.Add("notify_url", this.NotifyUrl);
            parameters.Add("return_url", this.ReturnUrl);
            parameters.Add("_error_notify_url", this.ErrorNotifyUrl);
           
            parameters.Add("out_trade_no", this.OutTradeNo);
            parameters.Add("subject", this.Subject);
            parameters.Add("payment_type", this.PaymentType);
            parameters.Add("total_fee", this.TotalFee.ToString());
            parameters.Add("seller_id", this.SellerID);
            parameters.Add("buyer_id", this.BuyerID);
            parameters.Add("seller_email", this.SellerEmail);
            parameters.Add("buyer_email", this.BuyerEmail);


            parameters.Add("price", this.Price.ToString());
            parameters.Add("quantity", this.Quantity.ToString());
                
            parameters.Add("body", this.Body);
            parameters.Add("show_url", this.ShowUrl);    
            parameters.Add("paymethod", this.Paymethod);
            parameters.Add("enable_paymethod",this.EnablePaymethod);         
            parameters.Add("extra_common_param", this.ExtraCommonParam);

            return parameters;
        }

       
    }
}
